<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商家提现列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>提现类型：</label>
                            <select name="belongType">
                                <option value="">所有</option>
                                <option value="0">零钱</option>
                                <option value="1">银行卡</option>
                            </select>
                        </li>
                        <li>
                            <label>订单号：</label>
                            <input type="text" name="orderNum"/>
                        </li>
                        <li>
                            <label>单位名称：</label>
                            <input type="text" name="shopCompany"/>
                        </li>
                        <li class="select-time">
                            <label>提现时间： </label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTime]"/>
                        </li>

                        <!--     <li>
                                 <label>订单状态：</label>
                                 <select name="status" th:with="type=${@dict.getType('pick_status')}">
                                     <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                 </select>
                             </li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--    <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="shopPick:shopPick:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="shopPick:shopPick:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="shopPick:shopPick:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="shopPick:shopPick:export">
                    <i class="fa fa-download"></i> 导出
                </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('shopPick:shopPick:edit')}]];
    var removeFlag = [[${@permission.hasPermi('shopPick:shopPick:remove')}]];
    var statusDatas = [[${@dict.getType('pick_status')}]];
    var prefix = ctx + "shopPick/shopPick";
    var data
    $(function () {
        toSum()

        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "商家提现",
            showSearch: false,
            showRefresh: false,
            showColumns: false,
            showToggle: false,
            showFooter: true,
            detailView: true,
            detailFormatter: detailFormatter,
            columns: [{
                checkbox: true
            },
                {
                    field: 'orderNum',
                    title: '订单号',
                    footerFormatter: function (row) {
                        return "汇总";
                    }
                },
                {
                    field: 'shopCompany',
                    title: '单位名称'
                },
                {
                    field: 'belongType',
                    title: '提现类型',
                    formatter: function (value, row, index) {
                        if (value == 0) {
                            return "<span class='badge badge-warning'>零钱</span>";
                        }
                        return "<span class='badge badge-primary'>银行卡</span>";
                    }
                },
                {
                    field: 'pickMoney',
                    title: '提现金额',
                    formatter: function (value, row, index) {
                        return value + "元";
                    },
                    footerFormatter: function (row) {
                        return data.pickMoneySum;
                    }
                },
                {
                    field: 'shopAdded',
                    title: '额外手续费',
                    formatter: function (value, row, index) {
                        return value + "元";
                    },
                    footerFormatter: function (row) {
                        return data.addMoneySum;
                    }
                },
                {
                    field: 'createTime',
                    title: '提现时间'
                },
                {
                    field: 'status',
                    title: '提现状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                }]
        };
        $.table.init(options);
    });

    function detailFormatter(index, row) {
        var html = [];
        $.each(row, function (key, value) {
            if (key == "accountName") {
                if (value) {
                    html.push('<p><b>开户名:</b> ' + value + '</p>');
                }
            }
            if (key == "bankNum") {
                if (value) {
                    html.push('<p><b>银行卡号:</b> ' + value + '</p>');
                }
            }
            if (key == "belongType" && value == 0) {
                html.push('<p style="color: #9ea6b9" >提现在该商家管理员微信零钱包</p>');
            }

        });
        return html.join('');
    }


    function toSum() {
        $.ajax({
            type: "POST",
            cache: false,
            data: $('#formId').serialize(),
            async: false,
            url: prefix + "/list",
            success: function (res) {
                data = res.pickSum;

            }
        });
    }
</script>
</body>
</html>